<template>
  <div class="reject">
    <div class="section">
      <h3>驳回</h3>
      <SearchItem @searchList="searchData" :type="4"></SearchItem>
    </div>
    <el-table
     :height="tabHeight"
      border
      style="width: 100%"
      align="center"
      :data="tableData"
      v-loading="loading"
    >
      <el-table-column prop="roId" label="ID" width="145"></el-table-column>
      <el-table-column prop="username" label="用户名" width="60"></el-table-column>
      <el-table-column prop="cpName" label="所属CP" width="60"></el-table-column>
      <el-table-column prop="gameName" label="游戏名" width="90"></el-table-column>
      <el-table-column prop="serverName" label="区服" width="90"></el-table-column>
      <el-table-column prop="roleName" label="角色名" width="110"></el-table-column>
      <el-table-column prop="roleId" label="角色ID"></el-table-column>
      <el-table-column prop="amount" label="申请金额" width="65"></el-table-column>
      <el-table-column prop="amountTotal" label="今日总金额" width="75"></el-table-column>
      <el-table-column prop="applyTime" label="申请时间"></el-table-column>
      <el-table-column prop="payTime" label="充值时间"></el-table-column>
      <el-table-column label="返利信息" width="60">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="showdialog(scope.row)">查看</el-button>
        </template>
      </el-table-column>
      <el-table-column label="玩家备注" width="60" prop="remark">
        <template slot-scope="scope">
          <el-button
            type="text"
            @click="showNotes(scope.row)"
            size="small"
            v-show="scope.row.remark"
          >查看</el-button>
        </template>
      </el-table-column>
      <el-table-column label="明细" width="40">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="showdetail(scope.row)">查看</el-button>
        </template>
      </el-table-column>
      <el-table-column label="备注" width="50">
        <template slot-scope="scope">
          <el-button type="text" @click="rejectNotes(scope.row)" v-show="scope.row.auditRemark">
            <i class="el-icon-chat-dot-round"></i>
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="bottom">
      <!-- 将分页器作为子组件引入 -->
      <el-pagination
        @current-change="handleCurrentChange"
        :current-page.sync="pagenationData.currentPage"
        :page-size="pagenationData.pageSize"
        :total="pagenationData.pageTotal"
        background
        layout="prev, pager, next"
        prev-text="上一页"
        next-text="下一页"
      ></el-pagination>
    </div>
    <!-- 查看返利信息 -->
    <ShowRebateDialog
      v-if="showRebateDialog.show"
      :isShow="showRebateDialog.show"
      :dialogRow="showRebateDialog.dialogRow"
      @closeDialog="hideRebateDialog"
    ></ShowRebateDialog>
    <!-- 返利明细 -->
    <DetailDialog
      v-if="detailDialog.show"
      :isShow="detailDialog.show"
      :dialogRow="detailDialog.dialogRow"
      @closeDialog="hideDetailDialog"
    ></DetailDialog>
  </div>
</template>
<script>
import { mapGetters } from "vuex";

import SearchItem from "@/components/search/SearchItem";
import ShowRebateDialog from "@/components/dialog/ShowRebateDialog";
import DetailDialog from "@/components/dialog/DetailDialog";

import permission from "@/directive/permission/index.js"; // 权限判断指令
import * as mutils from "@/utils/mUtils";
import { getrejectData, showrebateDetail } from "@/api/data";
export default {
  name: "reject",
  components: {
    SearchItem,
    ShowRebateDialog,
    DetailDialog
  },
  directives: { permission },
  data() {
    return {
      tabHeight: window.innerHeight - 200,
      multipleSelection: [], //复选框选中
      loading: true,
      pagenationData: {
        pageTotal: 0,
        currentPage: 1,
        pageSize: 20
      },
      pageData: {
        page: 1,
        limit: 20
      },
      showRebateDialog: {
        show: false,
        dialogRow: {}
      },
      detailDialog: {
        show: false,
        dialogRow: []
      },
      tableData: [],
      search: {}
    };
  },
  mounted() {
    this.getRejectList();
  },
  methods: {
    searchData(search) {
      this.pagenationData.currentPage = 1;
      this.search = search;
      this.search.page = 1;
      this.searchList();
    },
    searchList() {
      this.loading = true;
      const para = Object.assign({}, this.search);
      getrejectData(para).then(res => { 
        this.loading = false;
        this.pagenationData.pageTotal = res.data.count;
        this.tableData = res.data.list;
      });
    },

    // 获取驳回数据
    getRejectList() {
      const para = Object.assign({}, this.pageData);
      getrejectData(para).then(res => {
        this.loading = false;
        this.pagenationData.pageTotal = res.data.count;
        this.tableData = res.data.list;
      });
    },
    showdialog(row) {
      //返利信息弹框显示
      this.showRebateDialog.dialogRow = row; //将行内信息存储，方便弹框显示
      this.showRebateDialog.show = true;
    },
    showNotes(row) {
      //查看玩家备注
      this.$alert(row.remark, "玩家备注", {
        confirmButtonText: "确定",
        center: true
      });
    },
    showdetail(row) {
      let roId = {
        roId: row.roId
      };
      showrebateDetail(roId).then(res => {
        this.detailDialog.dialogRow = res.data.list;
        this.detailDialog.show = true;
      });
    },
    //查看驳回备注
    rejectNotes(row) {
      this.$alert(row.auditRemark, "玩家备注", {
        confirmButtonText: "确定",
        center: true
      });
    },
    // 上下分页
    handleCurrentChange(val) {
      this.pageData.page = val;
      this.search.page = val;
      this.searchList();
    },
    hideRebateDialog() {
      //关闭查看返利
      this.showRebateDialog.show = false;
    },
    hideDetailDialog() {
      this.detailDialog.show = false;
    }
  }
};
</script>
<style lang="scss">
.reject {
  .el-icon-circle-check {
    font-size: 18px;
    color: #67c23a;
  }
  .el-button:active {
    border-color: transparent;
  }

  .el-dialog__wrapper {
    .el-input {
      margin-left: 0;
      border: 0;
    }
    .el-input.is-disabled .el-input__inner {
      border: 0;
      background: transparent;
      color: #606266;
      cursor: auto;
      font-style: 13px;
    }
    .el-form-item {
      margin-bottom: 0;
    }
    .el-form-item__label {
      font-size: 13px;
    }
    .el-button {
      padding: 10px 35px;
    }
    .el-dialog__footer {
      padding-top: 0;
    }
  }
  .throughMan {
    color: #de4a63;
    font-size: 13px;
  }
}
.el-message-box--center .el-message-box__header {
  padding-top: 20px;
}
.el-message-box--center {
  padding-bottom: 20px;
}
.el-message-box__btns {
  margin-top: 10px;
}
</style>



